Java Code Examples for net.minecraft.util.math.MathHelper#getInt()

The following examples show how to use net.minecraft.util.math.MathHelper#getInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapGenTofuVillage.java    From TofuCraftReload with MIT License 6 votes vote down vote up
public MapGenTofuVillage(Map<String, String> map)
{
    this();

    for (Map.Entry<String, String> entry : map.entrySet())
    {
        if (((String)entry.getKey()).equals("size"))
        {
            this.size = MathHelper.getInt(entry.getValue(), this.size, 0);
        }
        else if (((String)entry.getKey()).equals("distance"))
        {
            this.distance = MathHelper.getInt(entry.getValue(), this.distance, 9);
        }
    }
}
 
Example 2
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public static StructureBoundingBox findPieceBox(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;
}
 
Example 3
Source File: BlockTofuGemOre.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@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)) {
        return MathHelper.getInt(rand, 1, 3);
    }
    return 0;
}
 
Example 4
Source File: BlockTofuOreDiamond.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@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))
    {
        return MathHelper.getInt(rand, 2, 5);
    }
    return 0;
}
 
Example 5
Source File: BlockSakuraDiamondOre.java    From Sakura_mod with MIT License 5 votes vote down vote up
@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)) {
        return MathHelper.getInt(rand, 3, 7);
    }
    return 0;
}
 
Example 6
Source File: LootTableHelper.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * shuffles items by changing their order and splitting stacks
 */
private static void shuffleItems(List<ItemStack> stacks, int slotCount, 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() > 4) {
            list.add(itemstack);
            iterator.remove();
        }
    }

    slotCount = slotCount - stacks.size();

    while (slotCount > 0 && !list.isEmpty()) {
        ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size() - 1));
        int i = MathHelper.getInt(rand, itemstack2.getCount() / 3, 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);
}
 
Example 7
Source File: GTBlockOre.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public int getExpDrop(IBlockState state, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) {
	if (this.equals(GTBlocks.oreIridium)) {
		return MathHelper.getInt(RANDOM, 3, 7);
	}
	if (this.equals(GTBlocks.oreRuby) || this.equals(GTBlocks.oreSapphire)) {
		return MathHelper.getInt(RANDOM, 2, 5);
	}
	return 0;
}
 
Example 8
Source File: VillagerCreationTofu.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) {
    return new PieceWeight(TofuVillagerHouse.class, 45, MathHelper.getInt(random, i, 4 + i));
}
 
Example 9
Source File: VillagerCreationWA.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public PieceWeight getVillagePieceWeight(Random random, int i) {
	return new PieceWeight(WAVillagerHouse.class, 50, MathHelper.getInt(random, i, 4 + i));
}
 
Example 10
Source File: BlockPepperCrop.java    From Sakura_mod with MIT License 4 votes vote down vote up
protected int getBonemealAgeIncrease(World worldIn) {
	return MathHelper.getInt(worldIn.rand, 2, 5);
}
 
Example 11
Source File: BlockVanillaCrop.java    From Sakura_mod with MIT License 4 votes vote down vote up
protected int getBonemealAgeIncrease(World worldIn) {
	return MathHelper.getInt(worldIn.rand, 2, 5);
}
 
Example 12
Source File: BlockGrapeVine.java    From Sakura_mod with MIT License 4 votes vote down vote up
protected int getBonemealAgeIncrease(World worldIn) {
	return MathHelper.getInt(worldIn.rand, 2, 5);
}
 
Example 13
Source File: BlockGrapeLeaves.java    From Sakura_mod with MIT License 4 votes vote down vote up
protected int getBonemealAgeIncrease(World worldIn) {
	return MathHelper.getInt(worldIn.rand, 2, 5);
}
 
Example 14
Source File: BlockChestnut.java    From Sakura_mod with MIT License 4 votes vote down vote up
protected int getBonemealAgeIncrease(World worldIn)
{
    return MathHelper.getInt(worldIn.rand, 2, 5);
}