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


Java MathHelper.getInt方法代码示例

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


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

示例1: MapGenStronghold

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public MapGenStronghold(Map<String, String> p_i2068_1_)
{
    this();

    for (Entry<String, String> entry : p_i2068_1_.entrySet())
    {
        if (((String)entry.getKey()).equals("distance"))
        {
            this.distance = MathHelper.getDouble((String)entry.getValue(), this.distance, 1.0D);
        }
        else if (((String)entry.getKey()).equals("count"))
        {
            this.structureCoords = new ChunkPos[MathHelper.getInt((String)entry.getValue(), this.structureCoords.length, 1)];
        }
        else if (((String)entry.getKey()).equals("spread"))
        {
            this.spread = MathHelper.getInt((String)entry.getValue(), this.spread, 1);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:21,代码来源:MapGenStronghold.java

示例2: StructureOceanMonument

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public StructureOceanMonument(Map<String, String> p_i45608_1_)
{
    this();

    for (Entry<String, String> entry : p_i45608_1_.entrySet())
    {
        if (((String)entry.getKey()).equals("spacing"))
        {
            this.spacing = MathHelper.getInt((String)entry.getValue(), this.spacing, 1);
        }
        else if (((String)entry.getKey()).equals("separation"))
        {
            this.separation = MathHelper.getInt((String)entry.getValue(), this.separation, 1);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:StructureOceanMonument.java

示例3: MapGenVillage

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public MapGenVillage(Map<String, String> map)
{
    this();

    for (Entry<String, String> entry : map.entrySet())
    {
        if (((String)entry.getKey()).equals("size"))
        {
            this.size = MathHelper.getInt((String)entry.getValue(), this.size, 0);
        }
        else if (((String)entry.getKey()).equals("distance"))
        {
            this.distance = MathHelper.getInt((String)entry.getValue(), this.distance, 9);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:MapGenVillage.java

示例4: func_190888_a

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void func_190888_a(IMerchant p_190888_1_, MerchantRecipeList p_190888_2_, Random p_190888_3_)
{
    Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(p_190888_3_);
    int i = MathHelper.getInt(p_190888_3_, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + p_190888_3_.nextInt(5 + i * 10) + 3 * i;

    if (enchantment.isTreasureEnchantment())
    {
        j *= 2;
    }

    if (j > 64)
    {
        j = 64;
    }

    p_190888_2_.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:20,代码来源:EntityVillager.java

示例5: MapGenScatteredFeature

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public MapGenScatteredFeature(Map<String, String> p_i2061_1_)
{
    this();

    for (Entry<String, String> entry : p_i2061_1_.entrySet())
    {
        if (((String)entry.getKey()).equals("distance"))
        {
            this.maxDistanceBetweenScatteredFeatures = MathHelper.getInt((String)entry.getValue(), this.maxDistanceBetweenScatteredFeatures, 9);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:MapGenScatteredFeature.java

示例6: findPieceBox

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static StructureBoundingBox findPieceBox(StructureVillagePieces.Start start, List<StructureComponent> p_175848_1_, Random rand, int p_175848_3_, int p_175848_4_, int p_175848_5_, EnumFacing facing)
{
    for (int i = 7 * MathHelper.getInt(rand, 3, 5); i >= 7; i -= 7)
    {
        StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p_175848_3_, p_175848_4_, p_175848_5_, 0, 0, 0, 3, 3, i, facing);

        if (StructureComponent.findIntersecting(p_175848_1_, structureboundingbox) == null)
        {
            return structureboundingbox;
        }
    }

    return null;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:StructureVillagePieces.java

示例7: generateFruitTree

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@SubscribeEvent
public void generateFruitTree(DecorateBiomeEvent.Decorate event) {
    if (event.getType() == DecorateBiomeEvent.Decorate.EventType.TREE) {
        BaseTreeGenerator[] generatorBasicTrees = generatorTreeMap.values().toArray(new BaseTreeGenerator[0]);
        BaseTreeGenerator generator = generatorBasicTrees[MathHelper.getInt(event.getRand(),0, generatorBasicTrees.length - 1)];
        if (generator.generate(event.getWorld(), event.getRand(), event.getPos())) {
            FoodCraftReloaded.getLogger().info("Generated fruit tree at " + event.getPos());
            event.setResult(Event.Result.DENY);
        }
    }
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:12,代码来源:FruitTreeGenerator.java

示例8: update

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Like the old updateEntity(), except more generic.
 */
public void update()
{
    MusicTicker.MusicType musicticker$musictype = this.mc.getAmbientMusicType();

    if (this.currentMusic != null)
    {
        if (!musicticker$musictype.getMusicLocation().getSoundName().equals(this.currentMusic.getSoundLocation()))
        {
            this.mc.getSoundHandler().stopSound(this.currentMusic);
            this.timeUntilNextMusic = MathHelper.getInt(this.rand, 0, musicticker$musictype.getMinDelay() / 2);
        }

        if (!this.mc.getSoundHandler().isSoundPlaying(this.currentMusic))
        {
            this.currentMusic = null;
            this.timeUntilNextMusic = Math.min(MathHelper.getInt(this.rand, musicticker$musictype.getMinDelay(), musicticker$musictype.getMaxDelay()), this.timeUntilNextMusic);
        }
    }

    this.timeUntilNextMusic = Math.min(this.timeUntilNextMusic, musicticker$musictype.getMaxDelay());

    if (this.currentMusic == null && this.timeUntilNextMusic-- <= 0)
    {
        this.playMusic(musicticker$musictype);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:30,代码来源:MusicTicker.java

示例9: shuffleItems

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * shuffles items by changing their order and splitting stacks
 */
private void shuffleItems(List<ItemStack> stacks, int p_186463_2_, Random rand)
{
    List<ItemStack> list = Lists.<ItemStack>newArrayList();
    Iterator<ItemStack> iterator = stacks.iterator();

    while (iterator.hasNext())
    {
        ItemStack itemstack = iterator.next();

        if (itemstack.isEmpty())
        {
            iterator.remove();
        }
        else if (itemstack.getCount() > 1)
        {
            list.add(itemstack);
            iterator.remove();
        }
    }

    p_186463_2_ = p_186463_2_ - stacks.size();

    while (p_186463_2_ > 0 && !list.isEmpty())
    {
        ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size() - 1));
        int i = MathHelper.getInt(rand, 1, itemstack2.getCount() / 2);
        ItemStack itemstack1 = itemstack2.splitStack(i);

        if (itemstack2.getCount() > 1 && rand.nextBoolean())
        {
            list.add(itemstack2);
        }
        else
        {
            stacks.add(itemstack2);
        }

        if (itemstack1.getCount() > 1 && rand.nextBoolean())
        {
            list.add(itemstack1);
        }
        else
        {
            stacks.add(itemstack1);
        }
    }

    stacks.addAll(list);
    Collections.shuffle(stacks, rand);
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:54,代码来源:CustomLootTable.java

示例10: getExpDrop

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Override
public int getExpDrop(IBlockState state, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) {
	Random rand = world instanceof World ? ((World) world).rand : new Random();
	return MathHelper.getInt(rand, 2, 5);
}
 
开发者ID:the-realest-stu,项目名称:Etheric,代码行数:6,代码来源:BlockLodestoneOre.java

示例11: getTreeHeight

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected int getTreeHeight(Random rand) {
    return MathHelper.getInt(rand, minHeight, maxHeight);
}
 
开发者ID:Boethie,项目名称:Genesis,代码行数:4,代码来源:WorldGenAbstractGenesisTree.java

示例12: getExpDrop

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Override
public int getExpDrop(IBlockState state, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune)
{
	Random rand = world instanceof World ? ((World)world).rand : new Random();
	return MathHelper.getInt(rand, 2, 5);
}
 
开发者ID:Lemonszz,项目名称:Anima-Mundi,代码行数:7,代码来源:BlockAnimaOre.java

示例13: 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.getInt(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.getInt(astring[j++], k);
                }

                flatgeneratorinfo.setBiome(k);

                if (i > 0 && astring.length > j)
                {
                    String[] astring1 = astring[j++].toLowerCase(Locale.ROOT).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:sudofox,项目名称:Backmemed,代码行数:79,代码来源:FlatGeneratorInfo.java

示例14: generateInt

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public int generateInt(Random rand)
{
    return MathHelper.getInt(rand, MathHelper.floor(this.min), MathHelper.floor(this.max));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:5,代码来源:RandomValueRange.java

示例15: getInt

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


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