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


Java MathHelper.getRandomIntegerInRange方法代码示例

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


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

示例1: update

import net.minecraft.util.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().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);
        }
    }

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

示例2: func_175848_a

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public static StructureBoundingBox func_175848_a(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:Notoh,项目名称:DecompiledMinecraft,代码行数:15,代码来源:StructureVillagePieces.java

示例3: modifyMerchantRecipeList

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    Enchantment enchantment = Enchantment.enchantmentsBookList[random.nextInt(Enchantment.enchantmentsBookList.length)];
    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 (j > 64)
    {
        j = 64;
    }

    recipeList.add(new MerchantRecipe(new ItemStack(Items.book), new ItemStack(Items.emerald, j), itemstack));
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:15,代码来源:EntityVillager.java

示例4: grow

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public void grow(World worldIn, BlockPos pos, IBlockState state)
{
    int i = ((Integer)state.getValue(AGE)).intValue() + MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5);

    if (i > 7)
    {
        i = 7;
    }

    worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(i)), 2);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:12,代码来源:BlockCrops.java

示例5: dropBlockAsItemWithChance

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Spawns this Block's drops into the World as EntityItems.
 */
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
    super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune);

    if (this.getItemDropped(state, worldIn.rand, fortune) != Item.getItemFromBlock(this))
    {
        int i = 0;

        if (this == Blocks.coal_ore)
        {
            i = MathHelper.getRandomIntegerInRange(worldIn.rand, 0, 2);
        }
        else if (this == Blocks.diamond_ore)
        {
            i = MathHelper.getRandomIntegerInRange(worldIn.rand, 3, 7);
        }
        else if (this == Blocks.emerald_ore)
        {
            i = MathHelper.getRandomIntegerInRange(worldIn.rand, 3, 7);
        }
        else if (this == Blocks.lapis_ore)
        {
            i = MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5);
        }
        else if (this == Blocks.quartz_ore)
        {
            i = MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5);
        }

        this.dropXpOnBlockBreak(worldIn, pos, i);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:36,代码来源:BlockOre.java

示例6: growStem

import net.minecraft.util.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:Notoh,项目名称:DecompiledMinecraft,代码行数:6,代码来源:BlockStem.java

示例7: tick

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Main function called by run() every loop.
 */
protected void tick()
{
    long i = System.nanoTime();
    ++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.setPlayerCountData(new ServerStatusResponse.PlayerCountData(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.serverConfigManager.func_181057_v().get(j + k)).getGameProfile();
        }

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

    if (this.tickCounter % 900 == 0)
    {
        this.theProfiler.startSection("save");
        this.serverConfigManager.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();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:61,代码来源:MinecraftServer.java

示例8: tick

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Main function called by run() every loop.
 */
public void tick()
{
    long i = System.nanoTime();
    ++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.setPlayerCountData(new ServerStatusResponse.PlayerCountData(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.serverConfigManager.func_181057_v().get(j + k)).getGameProfile();
        }

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

    if (this.tickCounter % 900 == 0)
    {
        this.theProfiler.startSection("save");
        this.serverConfigManager.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();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:61,代码来源:MinecraftServer.java

示例9: nextInt

import net.minecraft.util.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:SkidJava,项目名称:BaseClient,代码行数:5,代码来源:RealmsMth.java

示例10: growStem

import net.minecraft.util.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:SkidJava,项目名称:BaseClient,代码行数:5,代码来源:BlockStem.java


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