当前位置: 首页>>代码示例>>Java>>正文


Java MathHelper.parseIntWithDefault方法代码示例

本文整理汇总了Java中net.minecraft.util.math.MathHelper.parseIntWithDefault方法的典型用法代码示例。如果您正苦于以下问题:Java MathHelper.parseIntWithDefault方法的具体用法?Java MathHelper.parseIntWithDefault怎么用?Java MathHelper.parseIntWithDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.util.math.MathHelper的用法示例。


在下文中一共展示了MathHelper.parseIntWithDefault方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFlatGeneratorFromString

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static FlatGeneratorInfo createFlatGeneratorFromString(String flatGeneratorSettings)
{
    if (flatGeneratorSettings == null)
    {
        return getDefaultFlatGenerator();
    }
    else
    {
        String[] astring = flatGeneratorSettings.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 = getLayersFromString(i, astring[j++]);

            if (list != null && !list.isEmpty())
            {
                flatgeneratorinfo.getFlatLayers().addAll(list);
                flatgeneratorinfo.updateLayers();
                int k = Biome.getIdForBiome(Biomes.PLAINS);

                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].isEmpty())
                        {
                            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 (String s1 : astring3)
                                {
                                    String[] astring4 = s1.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();
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:79,代码来源:FlatGeneratorInfo.java

示例2: getInt

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static int getInt(String p_getInt_0_, int p_getInt_1_)
{
    return MathHelper.parseIntWithDefault(p_getInt_0_, p_getInt_1_);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:RealmsMth.java

示例3: getCoordinate

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private static double getCoordinate(Map<String, String> params, String key, double defaultD, boolean offset)
{
    return params.containsKey(key) ? (double)MathHelper.parseIntWithDefault((String)params.get(key), MathHelper.floor_double(defaultD)) + (offset ? 0.5D : 0.0D) : defaultD;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:EntitySelector.java

示例4: parseIntWithDefault

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private static int parseIntWithDefault(Map<String, String> params, String key, int defaultI)
{
    return params.containsKey(key) ? MathHelper.parseIntWithDefault((String)params.get(key), defaultI) : defaultI;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:EntitySelector.java

示例5: execute

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (sender instanceof CommandBlockBaseLogic)
    {
        sender.addChatMessage((new TextComponentString("Searge says: ")).appendText(seargeSays[this.rand.nextInt(seargeSays.length) % seargeSays.length]));
    }
    else
    {
        List<ICommand> list = this.getSortedPossibleCommands(sender, server);
        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.getCommandMap(server);
            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());
        TextComponentTranslation textcomponenttranslation1 = new TextComponentTranslation("commands.help.header", new Object[] {Integer.valueOf(k + 1), Integer.valueOf(j + 1)});
        textcomponenttranslation1.getStyle().setColor(TextFormatting.DARK_GREEN);
        sender.addChatMessage(textcomponenttranslation1);

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

        if (k == 0 && sender instanceof EntityPlayer)
        {
            TextComponentTranslation textcomponenttranslation2 = new TextComponentTranslation("commands.help.footer", new Object[0]);
            textcomponenttranslation2.getStyle().setColor(TextFormatting.GREEN);
            sender.addChatMessage(textcomponenttranslation2);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:60,代码来源:CommandHelp.java


注:本文中的net.minecraft.util.math.MathHelper.parseIntWithDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。