Java Code Examples for net.minecraft.util.MathHelper.parseIntWithDefault()

The following are Jave code examples for showing how to use parseIntWithDefault() of the net.minecraft.util.MathHelper class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: FlatGeneratorInfo.java   View Source Code Vote up 4 votes
public static FlatGeneratorInfo createFlatGeneratorFromString(String p_82651_0_)
{
    if (p_82651_0_ == null)
    {
        return getDefaultFlatGenerator();
    }
    else
    {
        String[] astring = p_82651_0_.split(";", -1);
        int i = astring.length == 1 ? 0 : MathHelper.parseIntWithDefault(astring[0], 0);

        if (i >= 0 && i <= 3)
        {
            FlatGeneratorInfo flatgeneratorinfo = new FlatGeneratorInfo();
            int j = astring.length == 1 ? 0 : 1;
            List<FlatLayerInfo> list = func_180716_a(i, astring[j++]);

            if (list != null && !list.isEmpty())
            {
                flatgeneratorinfo.getFlatLayers().addAll(list);
                flatgeneratorinfo.func_82645_d();
                int k = BiomeGenBase.plains.biomeID;

                if (i > 0 && astring.length > j)
                {
                    k = MathHelper.parseIntWithDefault(astring[j++], k);
                }

                flatgeneratorinfo.setBiome(k);

                if (i > 0 && astring.length > j)
                {
                    String[] astring1 = astring[j++].toLowerCase().split(",");

                    for (String s : astring1)
                    {
                        String[] astring2 = s.split("\\(", 2);
                        Map<String, String> map = Maps.<String, String>newHashMap();

                        if (astring2[0].length() > 0)
                        {
                            flatgeneratorinfo.getWorldFeatures().put(astring2[0], map);

                            if (astring2.length > 1 && astring2[1].endsWith(")") && astring2[1].length() > 1)
                            {
                                String[] astring3 = astring2[1].substring(0, astring2[1].length() - 1).split(" ");

                                for (int l = 0; l < astring3.length; ++l)
                                {
                                    String[] astring4 = astring3[l].split("=", 2);

                                    if (astring4.length == 2)
                                    {
                                        map.put(astring4[0], astring4[1]);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    flatgeneratorinfo.getWorldFeatures().put("village", Maps.<String, String>newHashMap());
                }

                return flatgeneratorinfo;
            }
            else
            {
                return getDefaultFlatGenerator();
            }
        }
        else
        {
            return getDefaultFlatGenerator();
        }
    }
}
 
Example 2
Project: DecompiledMinecraft   File: PlayerSelector.java   View Source Code Vote up 4 votes
private static int parseIntWithDefault(Map<String, String> p_179653_0_, String p_179653_1_, int p_179653_2_)
{
    return p_179653_0_.containsKey(p_179653_1_) ? MathHelper.parseIntWithDefault((String)p_179653_0_.get(p_179653_1_), p_179653_2_) : p_179653_2_;
}
 
Example 3
Project: DecompiledMinecraft   File: CommandHelp.java   View Source Code Vote up 4 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    List<ICommand> list = this.getSortedPossibleCommands(sender);
    int i = 7;
    int j = (list.size() - 1) / 7;
    int k = 0;

    try
    {
        k = args.length == 0 ? 0 : parseInt(args[0], 1, j + 1) - 1;
    }
    catch (NumberInvalidException numberinvalidexception)
    {
        Map<String, ICommand> map = this.getCommands();
        ICommand icommand = (ICommand)map.get(args[0]);

        if (icommand != null)
        {
            throw new WrongUsageException(icommand.getCommandUsage(sender), new Object[0]);
        }

        if (MathHelper.parseIntWithDefault(args[0], -1) != -1)
        {
            throw numberinvalidexception;
        }

        throw new CommandNotFoundException();
    }

    int l = Math.min((k + 1) * 7, list.size());
    ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.help.header", new Object[] {Integer.valueOf(k + 1), Integer.valueOf(j + 1)});
    chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
    sender.addChatMessage(chatcomponenttranslation1);

    for (int i1 = k * 7; i1 < l; ++i1)
    {
        ICommand icommand1 = (ICommand)list.get(i1);
        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(icommand1.getCommandUsage(sender), new Object[0]);
        chatcomponenttranslation.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getCommandName() + " "));
        sender.addChatMessage(chatcomponenttranslation);
    }

    if (k == 0 && sender instanceof EntityPlayer)
    {
        ChatComponentTranslation chatcomponenttranslation2 = new ChatComponentTranslation("commands.help.footer", new Object[0]);
        chatcomponenttranslation2.getChatStyle().setColor(EnumChatFormatting.GREEN);
        sender.addChatMessage(chatcomponenttranslation2);
    }
}
 
Example 4
Project: DecompiledMinecraft   File: FlatGeneratorInfo.java   View Source Code Vote up 4 votes
public static FlatGeneratorInfo createFlatGeneratorFromString(String p_82651_0_)
{
    if (p_82651_0_ == null)
    {
        return getDefaultFlatGenerator();
    }
    else
    {
        String[] astring = p_82651_0_.split(";", -1);
        int i = astring.length == 1 ? 0 : MathHelper.parseIntWithDefault(astring[0], 0);

        if (i >= 0 && i <= 3)
        {
            FlatGeneratorInfo flatgeneratorinfo = new FlatGeneratorInfo();
            int j = astring.length == 1 ? 0 : 1;
            List<FlatLayerInfo> list = func_180716_a(i, astring[j++]);

            if (list != null && !list.isEmpty())
            {
                flatgeneratorinfo.getFlatLayers().addAll(list);
                flatgeneratorinfo.func_82645_d();
                int k = BiomeGenBase.plains.biomeID;

                if (i > 0 && astring.length > j)
                {
                    k = MathHelper.parseIntWithDefault(astring[j++], k);
                }

                flatgeneratorinfo.setBiome(k);

                if (i > 0 && astring.length > j)
                {
                    String[] astring1 = astring[j++].toLowerCase().split(",");

                    for (String s : astring1)
                    {
                        String[] astring2 = s.split("\\(", 2);
                        Map<String, String> map = Maps.<String, String>newHashMap();

                        if (astring2[0].length() > 0)
                        {
                            flatgeneratorinfo.getWorldFeatures().put(astring2[0], map);

                            if (astring2.length > 1 && astring2[1].endsWith(")") && astring2[1].length() > 1)
                            {
                                String[] astring3 = astring2[1].substring(0, astring2[1].length() - 1).split(" ");

                                for (int l = 0; l < astring3.length; ++l)
                                {
                                    String[] astring4 = astring3[l].split("=", 2);

                                    if (astring4.length == 2)
                                    {
                                        map.put(astring4[0], astring4[1]);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    flatgeneratorinfo.getWorldFeatures().put("village", Maps.<String, String>newHashMap());
                }

                return flatgeneratorinfo;
            }
            else
            {
                return getDefaultFlatGenerator();
            }
        }
        else
        {
            return getDefaultFlatGenerator();
        }
    }
}
 
Example 5
Project: DecompiledMinecraft   File: RealmsMth.java   View Source Code Vote up 4 votes
public static int getInt(String p_getInt_0_, int p_getInt_1_)
{
    return MathHelper.parseIntWithDefault(p_getInt_0_, p_getInt_1_);
}
 
Example 6
Project: DecompiledMinecraft   File: PlayerSelector.java   View Source Code Vote up 4 votes
private static int parseIntWithDefault(Map<String, String> p_179653_0_, String p_179653_1_, int p_179653_2_)
{
    return p_179653_0_.containsKey(p_179653_1_) ? MathHelper.parseIntWithDefault((String)p_179653_0_.get(p_179653_1_), p_179653_2_) : p_179653_2_;
}
 
Example 7
Project: DecompiledMinecraft   File: CommandHelp.java   View Source Code Vote up 4 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    List<ICommand> list = this.getSortedPossibleCommands(sender);
    int i = 7;
    int j = (list.size() - 1) / 7;
    int k = 0;

    try
    {
        k = args.length == 0 ? 0 : parseInt(args[0], 1, j + 1) - 1;
    }
    catch (NumberInvalidException numberinvalidexception)
    {
        Map<String, ICommand> map = this.getCommands();
        ICommand icommand = (ICommand)map.get(args[0]);

        if (icommand != null)
        {
            throw new WrongUsageException(icommand.getCommandUsage(sender), new Object[0]);
        }

        if (MathHelper.parseIntWithDefault(args[0], -1) != -1)
        {
            throw numberinvalidexception;
        }

        throw new CommandNotFoundException();
    }

    int l = Math.min((k + 1) * 7, list.size());
    ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.help.header", new Object[] {Integer.valueOf(k + 1), Integer.valueOf(j + 1)});
    chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
    sender.addChatMessage(chatcomponenttranslation1);

    for (int i1 = k * 7; i1 < l; ++i1)
    {
        ICommand icommand1 = (ICommand)list.get(i1);
        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(icommand1.getCommandUsage(sender), new Object[0]);
        chatcomponenttranslation.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getCommandName() + " "));
        sender.addChatMessage(chatcomponenttranslation);
    }

    if (k == 0 && sender instanceof EntityPlayer)
    {
        ChatComponentTranslation chatcomponenttranslation2 = new ChatComponentTranslation("commands.help.footer", new Object[0]);
        chatcomponenttranslation2.getChatStyle().setColor(EnumChatFormatting.GREEN);
        sender.addChatMessage(chatcomponenttranslation2);
    }
}
 
Example 8
Project: BaseClient   File: FlatGeneratorInfo.java   View Source Code Vote up 4 votes
public static FlatGeneratorInfo createFlatGeneratorFromString(String p_82651_0_)
{
    if (p_82651_0_ == null)
    {
        return getDefaultFlatGenerator();
    }
    else
    {
        String[] astring = p_82651_0_.split(";", -1);
        int i = astring.length == 1 ? 0 : MathHelper.parseIntWithDefault(astring[0], 0);

        if (i >= 0 && i <= 3)
        {
            FlatGeneratorInfo flatgeneratorinfo = new FlatGeneratorInfo();
            int j = astring.length == 1 ? 0 : 1;
            List<FlatLayerInfo> list = func_180716_a(i, astring[j++]);

            if (list != null && !list.isEmpty())
            {
                flatgeneratorinfo.getFlatLayers().addAll(list);
                flatgeneratorinfo.func_82645_d();
                int k = BiomeGenBase.plains.biomeID;

                if (i > 0 && astring.length > j)
                {
                    k = MathHelper.parseIntWithDefault(astring[j++], k);
                }

                flatgeneratorinfo.setBiome(k);

                if (i > 0 && astring.length > j)
                {
                    String[] astring1 = astring[j++].toLowerCase().split(",");

                    for (String s : astring1)
                    {
                        String[] astring2 = s.split("\\(", 2);
                        Map<String, String> map = Maps.<String, String>newHashMap();

                        if (astring2[0].length() > 0)
                        {
                            flatgeneratorinfo.getWorldFeatures().put(astring2[0], map);

                            if (astring2.length > 1 && astring2[1].endsWith(")") && astring2[1].length() > 1)
                            {
                                String[] astring3 = astring2[1].substring(0, astring2[1].length() - 1).split(" ");

                                for (int l = 0; l < astring3.length; ++l)
                                {
                                    String[] astring4 = astring3[l].split("=", 2);

                                    if (astring4.length == 2)
                                    {
                                        map.put(astring4[0], astring4[1]);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    flatgeneratorinfo.getWorldFeatures().put("village", Maps.<String, String>newHashMap());
                }

                return flatgeneratorinfo;
            }
            else
            {
                return getDefaultFlatGenerator();
            }
        }
        else
        {
            return getDefaultFlatGenerator();
        }
    }
}
 
Example 9
Project: BaseClient   File: RealmsMth.java   View Source Code Vote up 4 votes
public static int getInt(String p_getInt_0_, int p_getInt_1_)
{
    return MathHelper.parseIntWithDefault(p_getInt_0_, p_getInt_1_);
}
 
Example 10
Project: BaseClient   File: PlayerSelector.java   View Source Code Vote up 4 votes
private static int parseIntWithDefault(Map<String, String> p_179653_0_, String p_179653_1_, int p_179653_2_)
{
    return p_179653_0_.containsKey(p_179653_1_) ? MathHelper.parseIntWithDefault((String)p_179653_0_.get(p_179653_1_), p_179653_2_) : p_179653_2_;
}
 
Example 11
Project: BaseClient   File: CommandHelp.java   View Source Code Vote up 4 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    List<ICommand> list = this.getSortedPossibleCommands(sender);
    int i = 7;
    int j = (list.size() - 1) / 7;
    int k = 0;

    try
    {
        k = args.length == 0 ? 0 : parseInt(args[0], 1, j + 1) - 1;
    }
    catch (NumberInvalidException numberinvalidexception)
    {
        Map<String, ICommand> map = this.getCommands();
        ICommand icommand = (ICommand)map.get(args[0]);

        if (icommand != null)
        {
            throw new WrongUsageException(icommand.getCommandUsage(sender), new Object[0]);
        }

        if (MathHelper.parseIntWithDefault(args[0], -1) != -1)
        {
            throw numberinvalidexception;
        }

        throw new CommandNotFoundException();
    }

    int l = Math.min((k + 1) * 7, list.size());
    ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.help.header", new Object[] {Integer.valueOf(k + 1), Integer.valueOf(j + 1)});
    chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
    sender.addChatMessage(chatcomponenttranslation1);

    for (int i1 = k * 7; i1 < l; ++i1)
    {
        ICommand icommand1 = (ICommand)list.get(i1);
        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(icommand1.getCommandUsage(sender), new Object[0]);
        chatcomponenttranslation.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getCommandName() + " "));
        sender.addChatMessage(chatcomponenttranslation);
    }

    if (k == 0 && sender instanceof EntityPlayer)
    {
        ChatComponentTranslation chatcomponenttranslation2 = new ChatComponentTranslation("commands.help.footer", new Object[0]);
        chatcomponenttranslation2.getChatStyle().setColor(EnumChatFormatting.GREEN);
        sender.addChatMessage(chatcomponenttranslation2);
    }
}
 
Example 12
Project: BaseClient   File: FlatGeneratorInfo.java   View Source Code Vote up 4 votes
public static FlatGeneratorInfo createFlatGeneratorFromString(String p_82651_0_)
{
    if (p_82651_0_ == null)
    {
        return getDefaultFlatGenerator();
    }
    else
    {
        String[] astring = p_82651_0_.split(";", -1);
        int i = astring.length == 1 ? 0 : MathHelper.parseIntWithDefault(astring[0], 0);

        if (i >= 0 && i <= 3)
        {
            FlatGeneratorInfo flatgeneratorinfo = new FlatGeneratorInfo();
            int j = astring.length == 1 ? 0 : 1;
            List<FlatLayerInfo> list = func_180716_a(i, astring[j++]);

            if (list != null && !list.isEmpty())
            {
                flatgeneratorinfo.getFlatLayers().addAll(list);
                flatgeneratorinfo.func_82645_d();
                int k = BiomeGenBase.plains.biomeID;

                if (i > 0 && astring.length > j)
                {
                    k = MathHelper.parseIntWithDefault(astring[j++], k);
                }

                flatgeneratorinfo.setBiome(k);

                if (i > 0 && astring.length > j)
                {
                    String[] astring1 = astring[j++].toLowerCase().split(",");

                    for (String s : astring1)
                    {
                        String[] astring2 = s.split("\\(", 2);
                        Map<String, String> map = Maps.<String, String>newHashMap();

                        if (astring2[0].length() > 0)
                        {
                            flatgeneratorinfo.getWorldFeatures().put(astring2[0], map);

                            if (astring2.length > 1 && astring2[1].endsWith(")") && astring2[1].length() > 1)
                            {
                                String[] astring3 = astring2[1].substring(0, astring2[1].length() - 1).split(" ");

                                for (int l = 0; l < astring3.length; ++l)
                                {
                                    String[] astring4 = astring3[l].split("=", 2);

                                    if (astring4.length == 2)
                                    {
                                        map.put(astring4[0], astring4[1]);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    flatgeneratorinfo.getWorldFeatures().put("village", Maps.<String, String>newHashMap());
                }

                return flatgeneratorinfo;
            }
            else
            {
                return getDefaultFlatGenerator();
            }
        }
        else
        {
            return getDefaultFlatGenerator();
        }
    }
}
 
Example 13
Project: BaseClient   File: RealmsMth.java   View Source Code Vote up 4 votes
public static int getInt(String p_getInt_0_, int p_getInt_1_)
{
    return MathHelper.parseIntWithDefault(p_getInt_0_, p_getInt_1_);
}
 
Example 14
Project: BaseClient   File: PlayerSelector.java   View Source Code Vote up 4 votes
private static int parseIntWithDefault(Map<String, String> p_179653_0_, String p_179653_1_, int p_179653_2_)
{
    return p_179653_0_.containsKey(p_179653_1_) ? MathHelper.parseIntWithDefault((String)p_179653_0_.get(p_179653_1_), p_179653_2_) : p_179653_2_;
}
 
Example 15
Project: BaseClient   File: CommandHelp.java   View Source Code Vote up 4 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    List<ICommand> list = this.getSortedPossibleCommands(sender);
    int i = 7;
    int j = (list.size() - 1) / 7;
    int k = 0;

    try
    {
        k = args.length == 0 ? 0 : parseInt(args[0], 1, j + 1) - 1;
    }
    catch (NumberInvalidException numberinvalidexception)
    {
        Map<String, ICommand> map = this.getCommands();
        ICommand icommand = (ICommand)map.get(args[0]);

        if (icommand != null)
        {
            throw new WrongUsageException(icommand.getCommandUsage(sender), new Object[0]);
        }

        if (MathHelper.parseIntWithDefault(args[0], -1) != -1)
        {
            throw numberinvalidexception;
        }

        throw new CommandNotFoundException();
    }

    int l = Math.min((k + 1) * 7, list.size());
    ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.help.header", new Object[] {Integer.valueOf(k + 1), Integer.valueOf(j + 1)});
    chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
    sender.addChatMessage(chatcomponenttranslation1);

    for (int i1 = k * 7; i1 < l; ++i1)
    {
        ICommand icommand1 = (ICommand)list.get(i1);
        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(icommand1.getCommandUsage(sender), new Object[0]);
        chatcomponenttranslation.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getCommandName() + " "));
        sender.addChatMessage(chatcomponenttranslation);
    }

    if (k == 0 && sender instanceof EntityPlayer)
    {
        ChatComponentTranslation chatcomponenttranslation2 = new ChatComponentTranslation("commands.help.footer", new Object[0]);
        chatcomponenttranslation2.getChatStyle().setColor(EnumChatFormatting.GREEN);
        sender.addChatMessage(chatcomponenttranslation2);
    }
}