package net.minecraft.block; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockRedstoneOre extends Block { private boolean field_150187_a; private static final String __OBFID = "CL_00000294"; public BlockRedstoneOre(boolean p_i45420_1_) { super(Material.rock); if (p_i45420_1_) { this.setTickRandomly(true); } this.field_150187_a = p_i45420_1_; } /** * How many world ticks before ticking */ public int tickRate(World worldIn) { return 30; } /** * Called when a player hits the block. Args: world, x, y, z, player */ public void onBlockClicked(World worldIn, int x, int y, int z, EntityPlayer player) { this.func_150185_e(worldIn, x, y, z); super.onBlockClicked(worldIn, x, y, z, player); } public void onEntityWalking(World worldIn, int x, int y, int z, Entity entityIn) { this.func_150185_e(worldIn, x, y, z); super.onEntityWalking(worldIn, x, y, z, entityIn); } /** * Called upon block activation (right click on the block). Args : world, x, y, z, player, side, hitX, hitY, hitZ. * Return : Swing hand (client), abort the block placement (server) */ public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ) { this.func_150185_e(worldIn, x, y, z); return super.onBlockActivated(worldIn, x, y, z, player, side, subX, subY, subZ); } private void func_150185_e(World p_150185_1_, int p_150185_2_, int p_150185_3_, int p_150185_4_) { this.func_150186_m(p_150185_1_, p_150185_2_, p_150185_3_, p_150185_4_); if (this == Blocks.redstone_ore) { p_150185_1_.setBlock(p_150185_2_, p_150185_3_, p_150185_4_, Blocks.lit_redstone_ore); } } /** * Ticks the block if it's been scheduled */ public void updateTick(World worldIn, int x, int y, int z, Random random) { if (this == Blocks.lit_redstone_ore) { worldIn.setBlock(x, y, z, Blocks.redstone_ore); } } public Item getItemDropped(int meta, Random random, int fortune) { return Items.redstone; } /** * Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive). */ public int quantityDroppedWithBonus(int maxBonus, Random random) { return this.quantityDropped(random) + random.nextInt(maxBonus + 1); } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random random) { return 4 + random.nextInt(2); } /** * Drops the block items with a specified chance of dropping the specified items */ public void dropBlockAsItemWithChance(World worldIn, int x, int y, int z, int meta, float chance, int fortune) { super.dropBlockAsItemWithChance(worldIn, x, y, z, meta, chance, fortune); } private Random rand = new Random(); @Override // World, meta, fortune public int getExpDrop(IBlockAccess worldIn, int meta, int fortune) { if (this.getItemDropped(meta, rand, fortune) != Item.getItemFromBlock(this)) { return 1 + rand.nextInt(5); } return 0; } /** * A randomly called display update to be able to add particles or other items for display */ @SideOnly(Side.CLIENT) public void randomDisplayTick(World worldIn, int x, int y, int z, Random random) { if (this.field_150187_a) { this.func_150186_m(worldIn, x, y, z); } } private void func_150186_m(World p_150186_1_, int p_150186_2_, int p_150186_3_, int p_150186_4_) { Random random = p_150186_1_.rand; double d0 = 0.0625D; for (int l = 0; l < 6; ++l) { double d1 = (double)((float)p_150186_2_ + random.nextFloat()); double d2 = (double)((float)p_150186_3_ + random.nextFloat()); double d3 = (double)((float)p_150186_4_ + random.nextFloat()); if (l == 0 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_ + 1, p_150186_4_).isOpaqueCube()) { d2 = (double)(p_150186_3_ + 1) + d0; } if (l == 1 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_ - 1, p_150186_4_).isOpaqueCube()) { d2 = (double)(p_150186_3_ + 0) - d0; } if (l == 2 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_, p_150186_4_ + 1).isOpaqueCube()) { d3 = (double)(p_150186_4_ + 1) + d0; } if (l == 3 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_, p_150186_4_ - 1).isOpaqueCube()) { d3 = (double)(p_150186_4_ + 0) - d0; } if (l == 4 && !p_150186_1_.getBlock(p_150186_2_ + 1, p_150186_3_, p_150186_4_).isOpaqueCube()) { d1 = (double)(p_150186_2_ + 1) + d0; } if (l == 5 && !p_150186_1_.getBlock(p_150186_2_ - 1, p_150186_3_, p_150186_4_).isOpaqueCube()) { d1 = (double)(p_150186_2_ + 0) - d0; } if (d1 < (double)p_150186_2_ || d1 > (double)(p_150186_2_ + 1) || d2 < 0.0D || d2 > (double)(p_150186_3_ + 1) || d3 < (double)p_150186_4_ || d3 > (double)(p_150186_4_ + 1)) { p_150186_1_.spawnParticle("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D); } } } /** * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null. */ protected ItemStack createStackedBlock(int meta) { return new ItemStack(Blocks.redstone_ore); } }