Java 类net.minecraft.util.EnumOS 实例源码

项目:PeripheralsPlusPlus    文件:SpeechManager.java   
public static boolean isWindows() {
    return Minecraft.getOs() == EnumOS.WINDOWS;
}
项目:PeripheralsPlusPlus    文件:SpeechManager.java   
public static boolean isMac() {
    return Minecraft.getOs() == EnumOS.MACOS;
}
项目:RuneCraftery    文件:GuiScreenTemporaryResourcePackSelect.java   
protected void func_73875_a(GuiButton p_73875_1_) {
   if(p_73875_1_.field_73742_g) {
      if(p_73875_1_.field_73741_f == 5) {
         File var2 = GuiScreenTemporaryResourcePackSelectSelectionList.func_110510_a(this.field_110346_c).func_110612_e();
         String var3 = var2.getAbsolutePath();
         if(Util.func_110647_a() == EnumOS.MACOS) {
            try {
               this.field_73882_e.func_98033_al().func_98233_a(var3);
               Runtime.getRuntime().exec(new String[]{"/usr/bin/open", var3});
               return;
            } catch (IOException var9) {
               var9.printStackTrace();
            }
         } else if(Util.func_110647_a() == EnumOS.WINDOWS) {
            String var4 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[]{var3});

            try {
               Runtime.getRuntime().exec(var4);
               return;
            } catch (IOException var8) {
               var8.printStackTrace();
            }
         }

         boolean var10 = false;

         try {
            Class var5 = Class.forName("java.awt.Desktop");
            Object var6 = var5.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
            var5.getMethod("browse", new Class[]{URI.class}).invoke(var6, new Object[]{var2.toURI()});
         } catch (Throwable var7) {
            var7.printStackTrace();
            var10 = true;
         }

         if(var10) {
            this.field_73882_e.func_98033_al().func_98233_a("Opening via system class!");
            Sys.openURL("file://" + var3);
         }
      } else if(p_73875_1_.field_73741_f == 6) {
         this.field_73882_e.func_71373_a(this.field_110347_a);
      } else {
         this.field_110346_c.func_77219_a(p_73875_1_);
      }

   }
}
项目:RuneCraftery    文件:Util.java   
public static EnumOS func_110647_a() {
   String var0 = System.getProperty("os.name").toLowerCase();
   return var0.contains("win")?EnumOS.WINDOWS:(var0.contains("mac")?EnumOS.MACOS:(var0.contains("solaris")?EnumOS.SOLARIS:(var0.contains("sunos")?EnumOS.SOLARIS:(var0.contains("linux")?EnumOS.LINUX:(var0.contains("unix")?EnumOS.LINUX:EnumOS.UNKNOWN)))));
}
项目:RuneCraftery    文件:EnumHelperClient.java   
public static EnumOS addOS2(String name)
{
    return addEnum(EnumOS.class, name);
}
项目:RuneCraftery    文件:GuiScreenTemporaryResourcePackSelect.java   
/**
 * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
 */
protected void actionPerformed(GuiButton par1GuiButton)
{
    if (par1GuiButton.enabled)
    {
        if (par1GuiButton.id == 5)
        {
            File file1 = GuiScreenTemporaryResourcePackSelectSelectionList.func_110510_a(this.field_110346_c).getDirResourcepacks();
            String s = file1.getAbsolutePath();

            if (Util.getOSType() == EnumOS.MACOS)
            {
                try
                {
                    this.mc.getLogAgent().logInfo(s);
                    Runtime.getRuntime().exec(new String[] {"/usr/bin/open", s});
                    return;
                }
                catch (IOException ioexception)
                {
                    ioexception.printStackTrace();
                }
            }
            else if (Util.getOSType() == EnumOS.WINDOWS)
            {
                String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[] {s});

                try
                {
                    Runtime.getRuntime().exec(s1);
                    return;
                }
                catch (IOException ioexception1)
                {
                    ioexception1.printStackTrace();
                }
            }

            boolean flag = false;

            try
            {
                Class oclass = Class.forName("java.awt.Desktop");
                Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
                oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {file1.toURI()});
            }
            catch (Throwable throwable)
            {
                throwable.printStackTrace();
                flag = true;
            }

            if (flag)
            {
                this.mc.getLogAgent().logInfo("Opening via system class!");
                Sys.openURL("file://" + s);
            }
        }
        else if (par1GuiButton.id == 6)
        {
            this.mc.displayGuiScreen(this.field_110347_a);
        }
        else
        {
            this.field_110346_c.actionPerformed(par1GuiButton);
        }
    }
}
项目:RuneCraftery    文件:EnumHelperClient.java   
public static EnumOS addOS2(String name)
{
    return addEnum(EnumOS.class, name);
}
项目:BetterNutritionMod    文件:EnumHelperClient.java   
public static EnumOS addOS2(String name)
{
    return addEnum(EnumOS.class, name);
}
项目:BetterNutritionMod    文件:GuiScreenTemporaryResourcePackSelect.java   
/**
 * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
 */
protected void actionPerformed(GuiButton par1GuiButton)
{
    if (par1GuiButton.enabled)
    {
        if (par1GuiButton.id == 5)
        {
            File file1 = GuiScreenTemporaryResourcePackSelectSelectionList.func_110510_a(this.field_110346_c).getDirResourcepacks();
            String s = file1.getAbsolutePath();

            if (Util.getOSType() == EnumOS.MACOS)
            {
                try
                {
                    this.mc.getLogAgent().logInfo(s);
                    Runtime.getRuntime().exec(new String[] {"/usr/bin/open", s});
                    return;
                }
                catch (IOException ioexception)
                {
                    ioexception.printStackTrace();
                }
            }
            else if (Util.getOSType() == EnumOS.WINDOWS)
            {
                String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[] {s});

                try
                {
                    Runtime.getRuntime().exec(s1);
                    return;
                }
                catch (IOException ioexception1)
                {
                    ioexception1.printStackTrace();
                }
            }

            boolean flag = false;

            try
            {
                Class oclass = Class.forName("java.awt.Desktop");
                Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
                oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {file1.toURI()});
            }
            catch (Throwable throwable)
            {
                throwable.printStackTrace();
                flag = true;
            }

            if (flag)
            {
                this.mc.getLogAgent().logInfo("Opening via system class!");
                Sys.openURL("file://" + s);
            }
        }
        else if (par1GuiButton.id == 6)
        {
            this.mc.displayGuiScreen(this.field_110347_a);
        }
        else
        {
            this.field_110346_c.actionPerformed(par1GuiButton);
        }
    }
}
项目:BetterNutritionMod    文件:Minecraft.java   
private void updateDisplayMode() throws LWJGLException
{
    HashSet hashset = new HashSet();
    Collections.addAll(hashset, Display.getAvailableDisplayModes());
    DisplayMode displaymode = Display.getDesktopDisplayMode();

    if (!hashset.contains(displaymode) && Util.getOSType() == EnumOS.MACOS)
    {
        Iterator iterator = macDisplayModes.iterator();

        while (iterator.hasNext())
        {
            DisplayMode displaymode1 = (DisplayMode)iterator.next();
            boolean flag = true;
            Iterator iterator1 = hashset.iterator();
            DisplayMode displaymode2;

            while (iterator1.hasNext())
            {
                displaymode2 = (DisplayMode)iterator1.next();

                if (displaymode2.getBitsPerPixel() == 32 && displaymode2.getWidth() == displaymode1.getWidth() && displaymode2.getHeight() == displaymode1.getHeight())
                {
                    flag = false;
                    break;
                }
            }

            if (!flag)
            {
                iterator1 = hashset.iterator();

                while (iterator1.hasNext())
                {
                    displaymode2 = (DisplayMode)iterator1.next();

                    if (displaymode2.getBitsPerPixel() == 32 && displaymode2.getWidth() == displaymode1.getWidth() / 2 && displaymode2.getHeight() == displaymode1.getHeight() / 2)
                    {
                        displaymode = displaymode2;
                        break;
                    }
                }
            }
        }
    }

    Display.setDisplayMode(displaymode);
    this.displayWidth = displaymode.getWidth();
    this.displayHeight = displaymode.getHeight();
}