(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
| 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 |
nothing calls this directly
no test coverage detected