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

Method onBlockActivated

src/main/java/net/minecraft/block/BlockBed.java:35–106  ·  view source on GitHub ↗
(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)

Source from the content-addressed store, hash-verified

33 }
34
35 public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
36 {
37 if (worldIn.isRemote)
38 {
39 return true;
40 }
41 else
42 {
43 if (state.getValue(PART) != BlockBed.EnumPartType.HEAD)
44 {
45 pos = pos.offset(state.getValue(FACING));
46 state = worldIn.getBlockState(pos);
47
48 if (state.getBlock() != this)
49 {
50 return true;
51 }
52 }
53
54 if (worldIn.provider.canRespawnHere() && worldIn.getBiomeGenForCoords(pos) != BiomeGenBase.hell)
55 {
56 if (state.getValue(OCCUPIED))
57 {
58 EntityPlayer entityplayer = this.getPlayerInBed(worldIn, pos);
59
60 if (entityplayer != null)
61 {
62 playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.occupied"));
63 return true;
64 }
65
66 state = state.withProperty(OCCUPIED, Boolean.FALSE);
67 worldIn.setBlockState(pos, state, 4);
68 }
69
70 EntityPlayer.EnumStatus entityplayer$enumstatus = playerIn.trySleep(pos);
71
72 if (entityplayer$enumstatus == EntityPlayer.EnumStatus.OK)
73 {
74 state = state.withProperty(OCCUPIED, Boolean.TRUE);
75 worldIn.setBlockState(pos, state, 4);
76 return true;
77 }
78 else
79 {
80 if (entityplayer$enumstatus == EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW)
81 {
82 playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.noSleep"));
83 }
84 else if (entityplayer$enumstatus == EntityPlayer.EnumStatus.NOT_SAFE)
85 {
86 playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.notSafe"));
87 }
88
89 return true;
90 }
91 }
92 else

Callers

nothing calls this directly

Calls 15

getPlayerInBedMethod · 0.95
setBlockToAirMethod · 0.80
getOppositeMethod · 0.80
getValueMethod · 0.65
getBlockStateMethod · 0.65
getBlockMethod · 0.65
getBiomeGenForCoordsMethod · 0.65
withPropertyMethod · 0.65
getXMethod · 0.65
getYMethod · 0.65
getZMethod · 0.65
offsetMethod · 0.45

Tested by

no test coverage detected