當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。