MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / onItemUse

Method onItemUse

src/main/java/net/minecraft/item/ItemRedstone.java:25–53  ·  view source on GitHub ↗

Called when a Block is right-clicked with this Item @param pos The block being right-clicked @param side The side being right-clicked

(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)

Source from the content-addressed store, hash-verified

23 * @param side The side being right-clicked
24 */
25 public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
26 {
27 boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos);
28 BlockPos blockpos = flag ? pos : pos.offset(side);
29
30 if (!playerIn.canPlayerEdit(blockpos, side, stack))
31 {
32 return false;
33 }
34 else
35 {
36 Block block = worldIn.getBlockState(blockpos).getBlock();
37
38 if (!worldIn.canBlockBePlaced(block, blockpos, false, side, null, stack))
39 {
40 return false;
41 }
42 else if (Blocks.redstone_wire.canPlaceBlockAt(worldIn, blockpos))
43 {
44 --stack.stackSize;
45 worldIn.setBlockState(blockpos, Blocks.redstone_wire.getDefaultState());
46 return true;
47 }
48 else
49 {
50 return false;
51 }
52 }
53 }
54}

Callers

nothing calls this directly

Calls 9

canPlayerEditMethod · 0.80
canBlockBePlacedMethod · 0.80
getDefaultStateMethod · 0.80
getBlockMethod · 0.65
getBlockStateMethod · 0.65
isReplaceableMethod · 0.45
offsetMethod · 0.45
canPlaceBlockAtMethod · 0.45
setBlockStateMethod · 0.45

Tested by

no test coverage detected