001 package net.minecraft.item; 002 003 import net.minecraft.block.Block; 004 import net.minecraft.creativetab.CreativeTabs; 005 import net.minecraft.entity.player.EntityPlayer; 006 import net.minecraft.world.World; 007 008 public class ItemRedstone extends Item 009 { 010 public ItemRedstone(int par1) 011 { 012 super(par1); 013 this.setCreativeTab(CreativeTabs.tabRedstone); 014 } 015 016 /** 017 * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return 018 * True if something happen and false if it don't. This is for ITEMS, not BLOCKS 019 */ 020 public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) 021 { 022 if (par3World.getBlockId(par4, par5, par6) != Block.snow.blockID) 023 { 024 if (par7 == 0) 025 { 026 --par5; 027 } 028 029 if (par7 == 1) 030 { 031 ++par5; 032 } 033 034 if (par7 == 2) 035 { 036 --par6; 037 } 038 039 if (par7 == 3) 040 { 041 ++par6; 042 } 043 044 if (par7 == 4) 045 { 046 --par4; 047 } 048 049 if (par7 == 5) 050 { 051 ++par4; 052 } 053 054 if (!par3World.isAirBlock(par4, par5, par6)) 055 { 056 return false; 057 } 058 } 059 060 if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) 061 { 062 return false; 063 } 064 else 065 { 066 if (Block.redstoneWire.canPlaceBlockAt(par3World, par4, par5, par6)) 067 { 068 --par1ItemStack.stackSize; 069 par3World.setBlockWithNotify(par4, par5, par6, Block.redstoneWire.blockID); 070 } 071 072 return true; 073 } 074 } 075 }