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


Java MathHelper.getRandomIntegerInRange方法代码示例

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


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

示例1: modifyMerchantRecipeList

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Affects the given MerchantRecipeList to possibly add or remove MerchantRecipes.
 */
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random);
    int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + random.nextInt(5 + i * 10) + 3 * i;

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

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

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

示例2: 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.getRandomIntegerInRange(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:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:StructureVillagePieces.java

示例3: 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();
    if (this.getItemDropped(state, rand, fortune) != Item.getItemFromBlock(this))
    {
        int i = 0;

        if (this == Blocks.COAL_ORE)
        {
            i = MathHelper.getRandomIntegerInRange(rand, 0, 2);
        }
        else if (this == Blocks.DIAMOND_ORE)
        {
            i = MathHelper.getRandomIntegerInRange(rand, 3, 7);
        }
        else if (this == Blocks.EMERALD_ORE)
        {
            i = MathHelper.getRandomIntegerInRange(rand, 3, 7);
        }
        else if (this == Blocks.LAPIS_ORE)
        {
            i = MathHelper.getRandomIntegerInRange(rand, 2, 5);
        }
        else if (this == Blocks.QUARTZ_ORE)
        {
            i = MathHelper.getRandomIntegerInRange(rand, 2, 5);
        }

        return i;
    }
    return 0;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:34,代码来源:BlockOre.java

示例4: 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.getRandomIntegerInRange(this.rand, 0, musicticker$musictype.getMinDelay() / 2);
        }

        if (!this.mc.getSoundHandler().isSoundPlaying(this.currentMusic))
        {
            this.currentMusic = null;
            this.timeUntilNextMusic = Math.min(MathHelper.getRandomIntegerInRange(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:F1r3w477,项目名称:CustomWorldGen,代码行数:30,代码来源:MusicTicker.java

示例5: generateInt

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

示例6: 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 = (ItemStack)iterator.next();

        if (itemstack.stackSize <= 0)
        {
            iterator.remove();
        }
        else if (itemstack.stackSize > 1)
        {
            list.add(itemstack);
            iterator.remove();
        }
    }

    p_186463_2_ = p_186463_2_ - stacks.size();

    while (p_186463_2_ > 0 && ((List)list).size() > 0)
    {
        ItemStack itemstack2 = (ItemStack)list.remove(MathHelper.getRandomIntegerInRange(rand, 0, list.size() - 1));
        int i = MathHelper.getRandomIntegerInRange(rand, 1, itemstack2.stackSize / 2);
        itemstack2.stackSize -= i;
        ItemStack itemstack1 = itemstack2.copy();
        itemstack1.stackSize = i;

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

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

    stacks.addAll(list);
    Collections.shuffle(stacks, rand);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:56,代码来源:LootTable.java

示例7: nextInt

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

示例8: getBonemealAgeIncrease

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected int getBonemealAgeIncrease(World worldIn)
{
    return MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:BlockCrops.java

示例9: growStem

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void growStem(World worldIn, BlockPos pos, IBlockState state)
{
    int i = ((Integer)state.getValue(AGE)).intValue() + MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5);
    worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(Math.min(7, i))), 2);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:6,代码来源:BlockStem.java

示例10: tick

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Main function called by run() every loop.
 */
public void tick()
{
    long i = System.nanoTime();
    net.minecraftforge.fml.common.FMLCommonHandler.instance().onPreServerTick();
    ++this.tickCounter;

    if (this.startProfiling)
    {
        this.startProfiling = false;
        this.theProfiler.profilingEnabled = true;
        this.theProfiler.clearProfiling();
    }

    this.theProfiler.startSection("root");
    this.updateTimeLightAndEntities();

    if (i - this.nanoTimeSinceStatusRefresh >= 5000000000L)
    {
        this.nanoTimeSinceStatusRefresh = i;
        this.statusResponse.setPlayers(new ServerStatusResponse.Players(this.getMaxPlayers(), this.getCurrentPlayerCount()));
        GameProfile[] agameprofile = new GameProfile[Math.min(this.getCurrentPlayerCount(), 12)];
        int j = MathHelper.getRandomIntegerInRange(this.random, 0, this.getCurrentPlayerCount() - agameprofile.length);

        for (int k = 0; k < agameprofile.length; ++k)
        {
            agameprofile[k] = ((EntityPlayerMP)this.playerList.getPlayerList().get(j + k)).getGameProfile();
        }

        Collections.shuffle(Arrays.asList(agameprofile));
        this.statusResponse.getPlayers().setPlayers(agameprofile);
        this.statusResponse.invalidateJson();
    }

    if (this.tickCounter % 900 == 0)
    {
        this.theProfiler.startSection("save");
        this.playerList.saveAllPlayerData();
        this.saveAllWorlds(true);
        this.theProfiler.endSection();
    }

    this.theProfiler.startSection("tallying");
    this.tickTimeArray[this.tickCounter % 100] = System.nanoTime() - i;
    this.theProfiler.endSection();
    this.theProfiler.startSection("snooper");

    if (!this.usageSnooper.isSnooperRunning() && this.tickCounter > 100)
    {
        this.usageSnooper.startSnooper();
    }

    if (this.tickCounter % 6000 == 0)
    {
        this.usageSnooper.addMemoryStatsToSnooper();
    }

    this.theProfiler.endSection();
    this.theProfiler.endSection();
    net.minecraftforge.fml.common.FMLCommonHandler.instance().onPostServerTick();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:64,代码来源:MinecraftServer.java


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