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

Method onItemUse

src/main/java/net/minecraft/item/ItemFireball.java:24–54  ·  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

22 * @param side The side being right-clicked
23 */
24 public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
25 {
26 if (worldIn.isRemote)
27 {
28 return true;
29 }
30 else
31 {
32 pos = pos.offset(side);
33
34 if (!playerIn.canPlayerEdit(pos, side, stack))
35 {
36 return false;
37 }
38 else
39 {
40 if (worldIn.getBlockState(pos).getBlock().getMaterial() == Material.air)
41 {
42 worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "item.fireCharge.use", 1.0F, (itemRand.nextFloat() - itemRand.nextFloat()) * 0.2F + 1.0F);
43 worldIn.setBlockState(pos, Blocks.fire.getDefaultState());
44 }
45
46 if (!playerIn.capabilities.isCreativeMode)
47 {
48 --stack.stackSize;
49 }
50
51 return true;
52 }
53 }
54 }
55}

Callers

nothing calls this directly

Calls 11

canPlayerEditMethod · 0.80
playSoundEffectMethod · 0.80
getDefaultStateMethod · 0.80
getBlockMethod · 0.65
getBlockStateMethod · 0.65
getXMethod · 0.65
getYMethod · 0.65
getZMethod · 0.65
offsetMethod · 0.45
getMaterialMethod · 0.45
setBlockStateMethod · 0.45

Tested by

no test coverage detected