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

Method onItemUse

src/main/java/net/minecraft/item/ItemBanner.java:36–85  ·  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

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

Callers

nothing calls this directly

Calls 13

floor_doubleMethod · 0.95
canPlayerEditMethod · 0.80
getDefaultStateMethod · 0.80
setItemValuesMethod · 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