BiomesOPlenty/common/biomesoplenty/blocks/BlockBOPAmethyst.java

183 lines
4 KiB
Java
Raw Normal View History

2013-05-03 13:00:44 +00:00
package biomesoplenty.blocks;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Items;
public class BlockBOPAmethyst extends Block
{
2013-11-06 22:04:21 +00:00
public static final String[] types = new String[] {"amethystore", "amethystblock", "rubyore", "rubyblock", "peridotore", "peridotblock", "topazore", "topazblock", "tanzaniteore", "tanzaniteblock", "malachiteore", "malachiteblock", "sapphireore", "sapphireblock"};
2013-05-31 10:34:02 +00:00
private Icon[] textures;
public BlockBOPAmethyst(int par1, Material par2Material)
{
super(par1, par2Material);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
setStepSound(Block.soundStoneFootstep);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[types.length];
for (int i = 0; i < types.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:"+types[i]);
2013-05-31 10:34:02 +00:00
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
public int getDamageValue(World world, int x, int y, int z) {
return world.getBlockMetadata(x, y, z);
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < types.length; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public float getBlockHardness(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
2013-11-11 01:16:06 +00:00
return (meta % 2 == 0) ? 3.0F : 5.0F;
2013-05-31 10:34:02 +00:00
}
@Override
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
{
int meta = world.getBlockMetadata(x, y, z);
2013-11-11 01:16:06 +00:00
return (meta % 2 == 0) ? 1.0F : 2.0F;
2013-05-31 10:34:02 +00:00
}
@Override
public int idDropped(int meta, Random par2Random, int par3)
{
return (meta % 2 == 0) ? Items.gems.get().itemID : this.blockID;
2013-05-31 10:34:02 +00:00
}
@Override
public int damageDropped(int meta)
{
if (meta == 0)
{
return 0;
}
if (meta == 1)
{
return meta;
}
if (meta == 2)
{
return 1;
}
if (meta == 3)
{
return meta;
}
if (meta == 4)
{
return 2;
}
if (meta == 5)
{
return meta;
}
if (meta == 6)
{
return 3;
}
if (meta == 7)
{
return meta;
}
if (meta == 8)
{
return 4;
}
if (meta == 9)
{
return meta;
}
if (meta == 10)
{
return 5;
}
if (meta == 11)
{
return meta;
}
if (meta == 12)
{
return 6;
}
if (meta == 13)
{
return meta;
}
return meta;
2013-05-31 10:34:02 +00:00
}
@Override
public int quantityDropped(int meta, int fortune, Random random)
{
2013-11-11 01:16:06 +00:00
return (meta % 2 == 0) ? quantityDroppedWithBonus(fortune, random) : 1;
2013-05-31 10:34:02 +00:00
}
@Override
public int quantityDroppedWithBonus(int bonus, Random par2Random)
{
if (bonus > 0 && blockID != this.idDropped(0, par2Random, bonus))
{
int rnd = par2Random.nextInt(bonus + 2) - 1;
if (rnd < 0) {
rnd = 0;
}
2013-11-11 01:16:06 +00:00
return this.quantityDropped(par2Random) * (rnd + 1);
2013-05-31 10:34:02 +00:00
}
else
2013-11-11 01:16:06 +00:00
return this.quantityDropped(par2Random);
2013-05-31 10:34:02 +00:00
}
@Override
public void dropBlockAsItemWithChance(World world, int par2, int par3, int par4, int par5, float par6, int par7)
{
super.dropBlockAsItemWithChance(world, par2, par3, par4, par5, par6, par7);
if (this.idDropped(par5, world.rand, par7) != blockID)
{
2013-11-11 01:16:06 +00:00
int var8 = MathHelper.getRandomIntegerInRange(world.rand, 3, 7);
2013-05-31 10:34:02 +00:00
this.dropXpOnBlockBreak(world, par2, par3, par4, var8);
}
}
2013-05-03 13:00:44 +00:00
}