Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.chef.mod.blocks;
- import java.util.Random;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.client.renderer.texture.IIconRegister;
- import net.minecraft.item.Item;
- import net.minecraft.util.MathHelper;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.world.World;
- import com.chef.mod.Chef;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- public class MyBlockOre extends Block
- {
- public MyBlockOre()
- {
- super(Material.rock);
- this.setCreativeTab(Chef.chefTab);
- }
- int pickaxe = 1;
- private String[] harvestTool = new String[16];
- private int[] harvestLevel = new int[]{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
- @Override
- public int getHarvestLevel(int metadata)
- {
- if (this == Chef.oreSaltOre) {
- this.getHarvestLevel(2);
- } else if (this == Chef.oreSaltOre2) {
- this.getHarvestLevel(1);
- }
- return getHarvestLevel(0);
- }
- public Item getItemDropped(int block, Random random, int j) {
- Item returnItem;
- if (this == Chef.oreSaltOre) {
- returnItem = Chef.itemSalt;
- } else if (this == Chef.oreSaltOre2) {
- returnItem = Chef.itemSalt;
- } else {
- returnItem = Item.getItemFromBlock(this);
- }
- return returnItem;
- }
- /**
- * Returns the quantity of items to drop on block destruction.
- */
- public int quantityDropped(Random random)
- {
- return this == Chef.oreSaltOre ? 2 + random.nextInt(3) : 1;
- }
- /**
- * Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive).
- */
- public int quantityDroppedWithBonus(int i, Random random)
- {
- if (i > 0 && Item.getItemFromBlock(this) != this.getItemDropped(0, random, i))
- {
- int j = random.nextInt(i + 2) - 1;
- if (j < 0)
- {
- j = 0;
- }
- return this.quantityDropped(random) * (j + 1);
- }
- else
- {
- return this.quantityDropped(random);
- }
- }
- /**
- * Drops the block items with a specified chance of dropping the specified items
- */
- public void dropBlockAsItemWithChance(World world, int x, int y, int z, int i, float hitX, int hitZ)
- {
- super.dropBlockAsItemWithChance(world, x, y, z, i, hitX, hitZ);
- }
- private Random rand = new Random();
- @Override
- public int getExpDrop(IBlockAccess p_149690_1_, int p_149690_5_, int p_149690_7_)
- {
- if (this.getItemDropped(p_149690_5_, rand, p_149690_7_) != Item.getItemFromBlock(this))
- {
- int exp = 0;
- if (this == Chef.oreSaltOre)
- {
- exp = MathHelper.getRandomIntegerInRange(rand, 0, 2);
- }
- else if (this == Chef.oreSaltOre2)
- {
- exp = MathHelper.getRandomIntegerInRange(rand, 0, 1);
- }
- return exp;
- }
- return 0;
- }
- /**
- * Determines the damage on the item the block drops. Used in cloth and wood.
- */
- public int damageDropped(int i)
- {
- return this == Chef.oreSaltOre ? 4 : 0;
- }
- @SideOnly(Side.CLIENT)
- public void registerBlockIcons(IIconRegister iconRegister) {
- this.blockIcon = iconRegister.registerIcon(Chef.modid + ":" + this.getUnlocalizedName().substring(5));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment