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

Method onItemUse

src/main/java/net/minecraft/item/ItemSign.java:29–78  ·  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

27 * @param side The side being right-clicked
28 */
29 public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
30 {
31 if (side == EnumFacing.DOWN)
32 {
33 return false;
34 }
35 else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
36 {
37 return false;
38 }
39 else
40 {
41 pos = pos.offset(side);
42
43 if (!playerIn.canPlayerEdit(pos, side, stack))
44 {
45 return false;
46 }
47 else if (!Blocks.standing_sign.canPlaceBlockAt(worldIn, pos))
48 {
49 return false;
50 }
51 else if (worldIn.isRemote)
52 {
53 return true;
54 }
55 else
56 {
57 if (side == EnumFacing.UP)
58 {
59 int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
60 worldIn.setBlockState(pos, Blocks.standing_sign.getDefaultState().withProperty(BlockStandingSign.ROTATION, i), 3);
61 }
62 else
63 {
64 worldIn.setBlockState(pos, Blocks.wall_sign.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
65 }
66
67 --stack.stackSize;
68 TileEntity tileentity = worldIn.getTileEntity(pos);
69
70 if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack))
71 {
72 playerIn.openEditSign((TileEntitySign)tileentity);
73 }
74
75 return true;
76 }
77 }
78 }
79}

Callers

nothing calls this directly

Calls 14

floor_doubleMethod · 0.95
setTileEntityNBTMethod · 0.95
canPlayerEditMethod · 0.80
getDefaultStateMethod · 0.80
getBlockMethod · 0.65
getBlockStateMethod · 0.65
withPropertyMethod · 0.65
getTileEntityMethod · 0.65
isSolidMethod · 0.45
getMaterialMethod · 0.45
offsetMethod · 0.45
canPlaceBlockAtMethod · 0.45

Tested by

no test coverage detected